﻿@inherits ActionsBlock
@{
    // a list of actions
    var list = new UL("actions");

    var actions = Model.MasterModel.ActionsModel.Actions;
    if (actions.Count > 5)
    {
        actions = actions
            .Where(a => !SpecialActions.Any(q => q.IsEqual(a.ActionName)))
            .ToList();
    }
    //if (actions.Count > 5)
    //{
    //    actions = actions
    //        .Where(a => !KnownQuickActions.Any(q => q.IsEqual(a.ActionName)))
    //        .ToList();
    //}

    foreach (var action in actions)
    {
        string imgPath = null;
        if(KnownQuickActions.Contains(action.ActionName))
        {
            imgPath = Context.CreateUrl("/i/quick/" + action.ActionName + ".png");
        }

        var link = new LI
        {
            new Anchor()
                .SetHref(CreateHref(action))
                .SetTitle(CreateTitle(action))
                .SetTarget(action.Target)
                .SetAttribute("data-assuremessage", Assure(action))
                .AddCssClassName(Assure(action).IsNotEmpty() ? "assure" : null)
                .AddControls
                (
                    imgPath.IsNotEmpty()
                    ? new Image(imgPath)
                        .SetAlt(CreateTitle(action) ?? CreateText(action))
                        .SetTitle(CreateTitle(action) ?? CreateText(action)) as IVisualControl
                    : new Div(),
                    new Span { new Literal(CreateText(action)) }
                )
        };
        list.Add(link);
    }
}
@AddControls(new Nav{list}.SetId("masterActions"))